package com.example.itensyuan0609.dh;

import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;

import androidx.appcompat.app.AppCompatActivity;

import com.example.itensyuan0609.R;
import com.example.itensyuan0609.util.CircleImage;

public class AnimForXmlActivity extends AppCompatActivity implements View.OnClickListener {

    private Button a;
    private Button b;
    private Button c;
    private Button d;
    private Button e;
    private CircleImage ima;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_anim_for_xml);
        initView();
    }

    private void initView() {
        a = (Button) findViewById(R.id.a);
        b = (Button) findViewById(R.id.b);
        c = (Button) findViewById(R.id.c);
        d = (Button) findViewById(R.id.d);
        e = (Button) findViewById(R.id.e);
        ima = (CircleImage) findViewById(R.id.ima);

        a.setOnClickListener(this);
        b.setOnClickListener(this);
        c.setOnClickListener(this);
        d.setOnClickListener(this);
        e.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.a:
                Animation animation = AnimationUtils.loadAnimation(this, R.anim.alpha);
                ima.startAnimation(animation);
                break;
            case R.id.b:
                Animation animation2 = AnimationUtils.loadAnimation(this, R.anim.scale);
                ima.startAnimation(animation2);
                break;
            case R.id.c:
                Animation animation1 = AnimationUtils.loadAnimation(this, R.anim.rotate);
                ima.startAnimation(animation1);
                break;
            case R.id.d:
                Animation animation3 = AnimationUtils.loadAnimation(this, R.anim.translate);
                ima.startAnimation(animation3);
                break;
            case R.id.e:

                break;
        }
    }
}
